import 'package:dailoz/constants.dart';
import 'package:dailoz/generated/l10n.dart';
import 'package:dailoz/size_config.dart';
import 'package:flutter/material.dart';

class LabelType extends StatelessWidget {
  const LabelType({
    Key? key,
    required this.labelName,
    required this.taskNum,
    required this.labelColor,
    this.boxHeight = 138.0,
    this.boxWidth = 138.0,
    this.childPadding = EdgeInsets.zero,
    this.mainAxisAlignment = MainAxisAlignment.center,
    this.crossAxisAlignment = CrossAxisAlignment.center,
    required this.child,
    this.onTap,
    this.labelNameColor = textColor,
    this.labelNameSize = 15.0,
    this.taskNumColor = const Color(0xff393939),
    this.taskNumSize = 13.0,
    this.padding = EdgeInsets.zero,
  }) : super(key: key);

  final String? labelName;
  final Color? labelNameColor;
  final double? labelNameSize;
  final int? taskNum;
  final Color? taskNumColor;
  final double? taskNumSize;
  final Color? labelColor;
  final double? boxHeight;
  final double? boxWidth;
  final EdgeInsetsGeometry? childPadding;
  final EdgeInsetsGeometry? padding;
  final MainAxisAlignment? mainAxisAlignment;
  final CrossAxisAlignment? crossAxisAlignment;
  final Widget? child;
  final GestureTapCallback? onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Padding(
        padding: padding!,
        child: Container(
          height: SizeConfig.getProportionateScreenHeight(boxHeight!),
          width: SizeConfig.getProportionateScreenWidth(boxWidth!),
          decoration: BoxDecoration(
            color: labelColor!,
            borderRadius: const BorderRadius.all(
              Radius.circular(14.0),
            ),
          ),
          child: Padding(
            padding: childPadding!,
            child: Column(
              mainAxisAlignment: mainAxisAlignment!,
              crossAxisAlignment: crossAxisAlignment!,
              children: [
                child!,
                SizedBox(
                  height: SizeConfig.getProportionateScreenHeight(11.0),
                ),
                Text(
                  labelName!,
                  style: Theme.of(context).textTheme.bodyText2?.copyWith(
                        fontSize:
                            SizeConfig.getProportionateFontSize(labelNameSize!),
                      ),
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                ),
                SizedBox(
                  height: SizeConfig.getProportionateScreenHeight(7.0),
                ),
                taskNum == null
                    ? Container()
                    : Text(
                        "$taskNum ${S.of(context).task}",
                        style: TextStyle(
                          color: taskNumColor!,
                          fontSize:
                              SizeConfig.getProportionateFontSize(taskNumSize!),
                        ),
                      ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
